home *** CD-ROM | disk | FTP | other *** search
- {*--------------------------------------------------------------------------*}
- {* To Use the COLOR features (Buttons, etc) you must: *}
- {* 0: Have your application be a PCOLOR_APP from this unit!!!! *}
- {* 1: Have your DIALOG be a PCOLOR_DIALOG from this unit! *}
- {* 2: Pascal-Code the PCOLOR_BUTTONS/PCOLOR_STATICTEXT exactly *}
- {* the same as if they were 'normal' TButton/TStaticText. *}
- {* 3: The FIELDS unit knows about these COLOR objects. *}
- {*--------------------------------------------------------------------------*}
- UNIT Color_App; {Colored Application Buttons/TEXT!!}
-
-
- INTERFACE
- USES App, {TVISION, modified version to handle COLOR buttons!}
- Dialogs, {TVISION, button}
- Views, {TVision, titlestr}
- Objects; {TVision, misc}
-
- CONST
- Button_Color_Default :byte = 0; {green}
- Button_Black :byte = 1;
- Button_Dk_Blue :byte = 2;
- Button_Green :byte = 3;
- Button_Cyan :byte = 4;
- Button_Red :byte = 5;
- Button_Purple :byte = 6;
- Button_Brown :byte = 7;
- Button_Grey :byte = 8;
-
- Button_Dk_Grey :byte = 9;
- Button_Lt_Blue :byte = 10;
- Button_Lt_Green :byte = 11;
- Button_Lt_Cyan :byte = 12;
- Button_Lt_Red :byte = 13;
- Button_Lt_Purple :byte = 14;
- Button_Yellow :byte = 15;
- Button_White :byte = 16;
-
- TYPE
- PColor_InputLine = ^Color_Inputline;
- Color_InputLine = OBJECT(TInputLine)
- constructor Init (var Bounds: TRect; AMaxLen: Integer;
- Button_Color_ID : byte); {new parameter!}
- function GetPalette : PPalette; virtual; {MUST Override!}
- private
- Color : word;
- end; {color_inputline}
-
-
- PColor_Button = ^Color_Button;
- Color_Button = object(DIALOGS.TButton)
- constructor Init (var Bounds : OBJECTS.TRect;
- ATitle : VIEWS.TTitleStr;
- ACommand : Word;
- AFlags : Byte;
- Button_Color_ID : byte); {new parameter!}
- function GetPalette : PPalette; virtual; {MUST Override!}
- procedure New_Color (Button_Color_ID : Byte);
- function Get_Color : integer;
- procedure Hide_Shadow;
- private
- Color : word;
- Shadow_Hidden : boolean;
- end; {Color_Button}
-
- PColor_StaticText = ^Color_StaticText;
- Color_StaticText = object(DIALOGS.TStaticText)
- constructor Init (var Bounds : OBJECTS.TRect;
- AText : string;
- Button_Color_ID : byte); {new parameter!}
- function GetPalette : PPalette; virtual; {MUST Override!}
- private
- Color : word;
- end; {Color_StaticText}
-
- PColor_Dialog = ^Color_Dialog;
- Color_Dialog = object(TDialog)
- constructor init (var bounds: TRect; ATitle: TTitleStr);
- function GetPalette : PPalette; virtual; {MUST Override!}
- end; {Color_Dialog}
-
-
- PColor_Application = ^Color_Application;
- {this elimates need to tweak APP.pas}
- Color_Application = object(TApplication)
- function GetPalette : PPalette; virtual; {MUST Override!}
- end; {Color_Application}
-
- {*-----------------------------------------------------------*}
- {* If you want blinking, you must call SetBlink(TRUE) *}
- {* after a color dialog *}
- {*-----------------------------------------------------------*}
- procedure SetBlink(State: Boolean);
-
-
- {*************************************************************************}
- {*************************************************************************}
- {*************************************************************************}
- IMPLEMENTATION
-
-
- {*************************************************************************}
- procedure SetBlink(State: Boolean); assembler; {by steve shafer}
- asm
- mov ax,$1003
- mov bl,state
- push bp
- int $10
- pop bp
- end; {setblink}
-
-
- {**************************************************************************}
- constructor Color_InputLine.Init;
- begin
- TInputLine.Init (Bounds, AMaxLen);
- Color := Button_Color_ID;
- end; {init}
-
- {**************************************************************************}
- function Color_InputLine.GetPalette : PPalette;
- const
- D_Palette : string[4] = '';
- begin
- {*-----------------------------------------------------------------------*}
- {* Must be VAR rather than const to RESET to default each time! *}
- {* (changes to a const version of D_Palette is REMEMBERED!) *}
- {*-----------------------------------------------------------------------*}
- {#19#19#20#21; => TVision default colors for TInputLine}
- D_Palette := TInputLine.GetPalette^;
-
- IF ((Color > 0) and (Color < 17)) THEN
- BEGIN
- D_Palette[1] := CHAR(30+(Color*3)); {normal}
- D_Palette[2] := D_Palette[1];
- D_Palette[3] := CHAR(30+(Color*3)+1); {selected}
- END;
-
- GetPalette := @D_Palette;
- end; {getpalette}
-
- {**************************************************************************}
- constructor Color_Button.Init;
- begin
- TButton.Init (Bounds, ATitle, ACommand, AFlags);
- Color := Button_Color_ID;
- Shadow_Hidden := FALSE;
- end; {init}
-
- {**************************************************************************}
- procedure Color_Button.New_Color;
- begin
- Color := Button_Color_ID;
- Draw; {display the change}
- end; {new_color}
-
- {**************************************************************************}
- function Color_Button.Get_Color : integer;
- begin
- Get_Color := Color;
- end; {get_color}
-
- {**************************************************************************}
- procedure Color_Button.Hide_Shadow;
- begin
- Shadow_Hidden := TRUE;
- Draw; {display the change}
- end; {hide_shadow}
-
- {**************************************************************************}
- function Color_Button.GetPalette : PPalette;
- {* NOTE: Colors assumes use of COLOR Monitor!!!! *}
- { bckgrnd / letters
- 49=NO SHADOW (maybe want to instead use char[1]?)
- 0 - black 4 - red 8 - dark gray C - light red
- 1 - blue 5 - magenta 9 - light blue D - light magenta
- 2 - green 6 - brown A - light green E - yellow
- 3 - cyan 7 - light gray B - light cyan F - white
- } {see pg 107 on methodology}
- const
- D_Palette : string[8] = '';
- begin
- {*-----------------------------------------------------------------------*}
- {* Must be VAR rather than const to RESET to default each time! *}
- {* (changes to a const version of D_Palette is REMEMBERED!) *}
- {*-----------------------------------------------------------------------*}
- {#10#11#12#13#14#14#14#15; => TVISION default colors for TButton}
- D_Palette := TButton.GetPalette^;
-
- IF ((Color > 0) and (Color < 17)) THEN
- BEGIN
- D_Palette[1] := CHAR(30+(Color*3)); {normal}
- D_Palette[2] := D_Palette[1]; {normal for highlights}
- D_Palette[3] := CHAR(30+(Color*3)+1); {selected button}
-
- D_Palette[5] := CHAR(30+(Color*3)+2); {shortcut}
- D_Palette[6] := D_Palette[5];
- D_Palette[7] := D_Palette[6];
- END;
- IF (Shadow_Hidden)
- THEN D_Palette[8] := #81; {set to EXTENDED set (background)}
-
- GetPalette := @D_Palette;
- end; {getpalette}
-
- {**************************************************************************}
- constructor Color_StaticText.Init;
- begin
- TStaticText.Init (Bounds, AText);
- Color := Button_Color_ID;
- end; {init}
-
- {**************************************************************************}
- function Color_StaticText.GetPalette : PPalette;
- const
- D_Palette : string[1] = '';
- begin
- {*-----------------------------------------------------------------------*}
- {* Must be VAR rather than const to RESET to default each time! *}
- {* (changes to a const version of D_Palette is REMEMBERED!) *}
- {*-----------------------------------------------------------------------*}
- {#6; => TVISION default colors for TButton}
- D_Palette := TStaticText.GetPalette^; {TVision default colors for TStaticText}
-
- IF ((Color > 0) and (Color < 17))
- THEN D_Palette[1] := CHAR(30+(Color*3)); {normal}
-
- GetPalette := @D_Palette;
- end; {getpalette}
-
-
- {**************************************************************************}
- constructor Color_Dialog.Init (var bounds: TRect; ATitle: TTitleStr);
- begin
- TDialog.Init (bounds, ATitle);
- SetBlink(False);
- end; {init}
-
- {**************************************************************************}
- function Color_Dialog.GetPalette : PPalette;
- const
- (*#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52#53#54+
- #55#56#57#58#59#60#61#62#63+ {end of default CDialog}
- {*--------------------------------------------------------*}
- {* positions 33..110 is mapped similar pg 230 CDialog into *}
- {* a MODIFIED APP.CColor! *}
- {*--------------------------------------------------------*}
- *)
- New_Palette : string[49] = {32}
- #64#65#66+
- #67#68#69+
- #70#71#72+
- #73#74#75+
- #76#77#78+
- #79#80#81+
- #82#83#84+
- #85#86#87+
-
- #88#89#90+ {dk gray}
- #91#92#93+ {lt blue}
- #94#95#96+ {lt green}
- #97#98#99+ {lt cyan}
- #100#101#102+ {lt red}
- #103#104#105+ {lt magenta}
- #106#107#108+ {yellow}
- #109#110#111+ {white}
- #112; {hide-shadow}
- D_Palette : string [32+49] = ''; {32+new}
- begin
- D_Palette := TDialog.GetPalette^ + {TVision default colors for TDialog}
- New_Palette;
- GetPalette := @D_Palette;
- end; {getpalette}
-
- {**************************************************************************}
- function Color_Application.GetPalette : PPalette;
- const
- (* #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52#53#54+
- #55#56#57#58#59#60#61#62#63+ {end of default CDialog}
- {*--------------------------------------------------------*}
- {* positions 32..63 is mapped similar pg 230 CDialog into *}
- {* a MODIFIED APP.CColor! *}
- {*--------------------------------------------------------*}
- *)
- {*----------------------------------------*}
- {* DWH Specific access for COLORS/TEXT! *}
- {* (since dont have MULTI-inheritance) *}
- {*----------------------------------------*}
- New_Palette : string[49] = {31}
- #$07#$0F#$0E+
- #$17#$1F#$1E+
- #$20#$2F#$2E+
- #$30#$3F#$3E+
- #$40#$4F#$4E+
- #$50#$5F#$5E+
- #$60#$6F#$6E+
- #$70#$7F#$7E+
-
- #$80#$8F#$8E+ {dk gray}
- #$90#$9F#$9E+ {lt blue}
- #$A0#$AF#$AE+ {lt green}
- #$B0#$BF#$BE+ {lt cyan}
- #$C0#$CF#$CE+ {lt red}
- #$D0#$DF#$DE+ {lt magenta}
- #$E0#$E7#$E2+ {yellow}
- #$F0#$F7#$F2+ {white}
- #$77; {hide the shadow}
- CONST
- D_Palette : string [63+49] = '';
- begin
- D_Palette := TApplication.GetPalette^ + {TVision default colors for TDialog}
- + New_Palette;
- GetPalette := @D_Palette;
- end; {getpalette}
-
-
- END. {color_App}
-